package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.CreateEngineerProjectTask;
import com.shrcl.engineerprocess.domain.EngineerCostEstimation;
import com.shrcl.engineerprocess.domain.EngineerProject;
import com.shrcl.engineerprocess.domain.impl.EngineerCostEstimationImpl;
import com.shrcl.engineerprocess.domain.impl.EngineerNotitableTaskExtensionImpl;
import com.shrcl.engineerprocess.domain.proxy.CreateEngineerProjectTaskProxy;
import com.shrct.businessprocess.project.RCProject;
import edu.fudan.langlab.domain.task.TSKTask;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("CREATEENGINEERPROJECTTASK_TYPE")
public class CreateEngineerProjectTaskImpl extends EngineerNotitableTaskExtensionImpl implements CreateEngineerProjectTask {
  public CreateEngineerProjectTaskImpl() {
    super();
  }
  
  @JoinColumn(name = "engineerCostEstimation_id")
  @ManyToOne(targetEntity = EngineerCostEstimationImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private EngineerCostEstimation engineerCostEstimation;
  
  public EngineerCostEstimation getEngineerCostEstimation() {
    return this.engineerCostEstimation;
  }
  
  public CreateEngineerProjectTask setEngineerCostEstimation(final EngineerCostEstimation engineerCostEstimation) {
    this.engineerCostEstimation = engineerCostEstimation;
    return this;			
    
  }
  
  public String getTaskType() {
    return "CreateEngineerProjectTask";
  }
  
  public String getTaskName() {
    return "\u670D\u52A1\u7ACB\u9879";
  }
  
  public String getTaskDescription() {
    RCProject _project = this.engineerCostEstimation.getProject();
    String _name = _project.getName();
    String _plus = ("[" + _name);
    String _plus_1 = (_plus + "]");
    String _plus_2 = (_plus_1 + "\u670D\u52A1\u7ACB\u9879\u4EFB\u52A1");
    return _plus_2;
  }
  
  public void performCommit(final EngineerProject engineerProject) {
    this.engineerCostEstimation.engineerProjectKickOffNotify();
    engineerProject.kickoff();
    TSKTask _task = this.getTask();
    _task.finish();
  }
  
  public void performReject() {
    TSKTask _task = this.getTask();
    _task.finish();
  }
  
  public static CreateEngineerProjectTask create(final IObjectFactory objectFactory) {
    com.shrcl.engineerprocess.domain.CreateEngineerProjectTask createEngineerProjectTask = new com.shrcl.engineerprocess.domain.impl.CreateEngineerProjectTaskImpl(
    );
    objectFactory.create(createEngineerProjectTask);
    return createEngineerProjectTask;			
    
  }
  
  public static CreateEngineerProjectTask createCreateEngineerProjectTaskImpl(final IObjectFactory objectFactory, final Procedure1<CreateEngineerProjectTask> init) {
    com.shrcl.engineerprocess.domain.CreateEngineerProjectTask createEngineerProjectTask = new com.shrcl.engineerprocess.domain.impl.CreateEngineerProjectTaskImpl(
    );
    objectFactory.create(createEngineerProjectTask);
    init.apply(createEngineerProjectTask);
    
    return createEngineerProjectTask;			
    
  }
  
  public CreateEngineerProjectTaskProxy toProxy() {
    com.shrcl.engineerprocess.domain.proxy.CreateEngineerProjectTaskProxy proxy = new com.shrcl.engineerprocess.domain.proxy.CreateEngineerProjectTaskProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
